<template>
  <div>
    <el-button :plain="true" type="info" @click="click">点我(信息按钮)</el-button>
    <el-button :plain="true" type="danger" @click="open">弹窗(危险按钮)</el-button>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose">
      <span>这是一段信息</span>
      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
          prop="date"
          label="日期"
          width="180">
        </el-table-column>
        <el-table-column
          prop="name"
          label="姓名"
          width="180">
        </el-table-column>
        <el-table-column
          prop="address"
          label="地址">
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script type="text/ecmascript-6">

  export default {
    data() {
      return {
        dialogVisible: false,
        tableData: [{
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        }, {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }, {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄'
        }]
      }
    },
    methods: {
      click() {
        this.$notify.info({
          title: '通知',
          message: '这是一条提示消息'
        });
        this.$ajax({
          method: 'get',
          url: 'http://localhost:8080/#/ajax'
        })
          .then((response) => {
            console.log(JSON.stringify(response))
          })
          .catch((error) => {
            console.log(error)
          })
        this.dialogVisible = true;
      },
      handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {
          });
      },
      open() {
        this.$notify.error({
          title: '错误',
          message: '这是一条错误的提示消息'
          // type:'error' //效果一样
        });
      }
    }
  }
</script>
